#include<encode_manager.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


#include <unistd.h>

      

#include <sys/mman.h>


int main(int argc, char** argv)
{
	int fd_text;
	int err;
	struct stat statbuf;
	unsigned char* text_mem;
	
	if(argc != 2)
	{
		printf("Usage: %s <.txt>\n", argv[0]);
		return -1;
	}
	
	EncodeSystemRegister();
	 
	fd_text = open(argv[1],O_RDONLY);
	if(fd_text < 0)
	{
		printf("open %s err\n", argv[1]);
		return -1;
	}


    err = fstat(fd_text, &statbuf);
	if(err < 0)
	{
		printf("fstat %s err\n", argv[1]);
		return -1;
		
	}
	
	text_mem = (unsigned char*)mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd_text, 0);
	if(text_mem == (unsigned char*) -1)	
	{
		printf("mmap err\n");
		return -1;
	}
	
	text_mem
	
	return 0;
}
